<template>
  <view class="query_container">

    <!-- 商品展示区域 -->
    <!-- <scroll-view
      :scroll-y="true"
      class="scroll-y"
      @scrolltolower="scroll_bottom"
    >
      <good-info
        :goodsList="goodList"
        @reload="reload"
        :promotion="false"
        :out="false"
        type="out"
        :query="false"
        v-if="goodList.length > 0"
      ></good-info>
    </scroll-view> -->
    <view class="out_goods flex-c" v-if="good_info.id">
      <image :src="good_info.cover_image" mode="" class="cover_img"/>
      <view class="good_title" >{{good_info.goods_title}}</view>
      <view class="divide"></view>
      <view class="data_container" style="font-size:26rpx">
        <view class="left_price_box">
          <view>价格 ￥{{good_info.price2}} ~ ￥{{good_info.price}}</view>
        </view>
        <view class="middle_commision">佣金率 {{good_info.commission_rate*100}}%</view>
        <view class="amt_count">库存 {{good_info.goods_available_amt}}</view>
      </view>
    </view>
    <view class="empty" style="text-align: center" v-if="!good_info.id"
        >暂无商品,去添加</view
      >
      <view class="toAssistant1" @tap="go_change_outgoods">更换曝光产品</view>
    <!-- <van-empty description="描述文字" /> -->

    <!-- 商品展示区域 -->

    <van-toast id="van-toast" />
    <van-dialog id="van-dialog" zIndex="99999999999" />
  </view>
</template>

<script>
import GoodInfo from "../components/good_info";
import Dialog from "../../wxcomponents/vant/dialog/dialog";
import {
  show_mchnear_goods
} from "../../utils/imapi";
export default {
  props: {},
  components: {
    GoodInfo,
  },
  data() {
    return {
      value: "",
      option1: [
        { text: "全部", value: "" },
        { text: "仓库中", value: 0 },
        { text: "已上架", value: 1 },
        { text: "提审中", value: 2 },
        { text: "审核成功", value: 3 },
        { text: "审核失败", value: 4 },
      ],
      value1: 0,
      goodList: [],
      mch_type: "",
      mode_show:false,
      good_info:{}
    };
  },
  computed: {},
  watch: {},
  onLoad(options) {

  },
  onReady() {},
  onShow() {
    this.query_all_goods();
  },
  methods: {
    async query_all_goods() {
      try {
        const data = await show_mchnear_goods();
        console.log(data);
        if (data.code == 0) {
            this.good_info=data.data
          // console.log(this.goodList);
          // if(this.goodList.length>0) {
          //   this.goodList=[]

          // }
        }
      } catch (error) {}
    },
    reload() {
      this.queryparam.page_index = 1;
      this.query_all_goods();
    },
    status_change(e) {
      console.log(e.detail);
      this.queryparam.goods_status = e.detail;
      console.log(this.queryparam.goods_status);
    },
    inputchange(e) {
      console.log(e.detail);
      this.queryparam.title = e.detail.value;
    },
    reset() {
      this.queryparam = {
        goods_status: "",
        page_index: 1,
        page_size: 10,
        title: "",
      };
      this.query_all_goods();
    },
    thequery() {
      console.log(this.queryparam.title);
      this.query_all_goods();
    },

    async scroll_bottom() {
      console.log("触底了");
      this.queryparam.page_index++;
      try {
        const data = await query_all_goods(this.queryparam);
        const toast = this.$toast.loading("加载中");
        if (data.code == 0) {
          this.goodList.push(...data.data);
          console.log(data);
          toast.clear();
          if (data.data.length == 0) {
            this.queryparam.page_index--;

            this.$toast("全部加载");
          }
        }
      } catch (error) {}
    },
    // cancle_output(e) {
    //   const that = this;
    //   console.log(e.goods.id);
    //   const id = e.goods.id;
    //   Dialog.confirm({
    //     message: "确定要取消设置曝光此商品?",
    //   })
    //     .then(async () => {
    //       // on confirm
    //       try {
    //         const data = await set_mchnear_goods({
    //           goods_id: id,
    //         });
    //         console.log(data);
    //         if (data.code == 0) {
    //           that.$toast("设置成功");
    //         }
    //       } catch (error) {
    //         console.log(error);
    //         that.$toast("请稍后重试");
    //       }
    //     })
    //     .catch(() => {
    //       // on cancel
    //     });
    // },
    set_tg(e) {
      const that = this;
      console.log(e.goods.id);
      const id = e.goods.id;
      this.good_info=e.goods
      this.mode_show=true
    },
    // choose_mode(e) {
    //   const that = this
    //   console.log(e);
    //   const mode = Number(e.detail.className)
    //      Dialog.confirm({
    //     message: "确定要购买此套餐?",
    //   })
    //     .then(async () => {
    //       // on confirm
    //       try {
    //         const data = await set_tj_goods({
    //           goods_id: that.good_info.id,
    //           day_mode:mode
    //         });
    //         console.log(data);
    //         if (data.code == 0) {
    //           that.$toast("购买成功");
    //         }
    //       } catch (error) {
    //         console.log(error);
    //         // that.$toast("请稍后重试");
    //       }
    //     })
    //     .catch(() => {
    //       // on cancel
    //     });
    // },
    go_change_outgoods() {
      uni.navigateTo({
         url: '/pages/query_bargin_goods/query_bargin_goods?type=out'
      });
    }
  },
  onReachBottom() {},
  onHide() {},
};
</script>

<style scoped lang="scss" scoped>
.query_container {
.scroll-y {
  height:100vh;
}
}
.cover_img {
  width: 654rpx;
  height: 432rpx;
  margin: 40rpx 0 24rpx;
}
.good_title {
font-size: 48rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #0A0819;
margin-bottom: 22rpx;
}
.divide {
  width: 100%;
  height: 2rpx;
  background-color: #F0EEFD;
}
.data_container {
  width: 90%;
  display: flex;
  justify-content: space-around;
  margin-top: 12rpx;
}
.toAssistant1 {
  position: fixed;
  bottom: 10upx;
  width: 690upx;
  left: 30upx;
  /* right: 0; */
  height: 80upx;
  background: #f03752;
  border-radius: 50upx;
  text-align: center;
  line-height: 80upx;
  font-size: 32upx;
  color: #fff;
  font-weight: 600;
  font-family: PingFangSC-Semibold, PingFang SC;
  z-index: 99;
  /* margin-top: 60upx; */
}
</style>
